﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.IO;
using System.ComponentModel;
using System.Web.Configuration;

namespace HospitalSystem
{
    public partial class servicerecordcheck : System.Web.UI.Page
    {
               public static List<string> x2 = new List<string>();
        public static List<string> x = new List<string>();
        DataTable dt = new DataTable();

        DataTable da = new DataTable();
   
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {

               // BindData();
                String ShowValue = (string)Session["CID"];
               Label1.Text = ShowValue;





               Bindcase();
            }
        }
               protected void Bindcase()
        {
            string constr = WebConfigurationManager.ConnectionStrings["strconnection"].ConnectionString;
            SqlConnection scon = new SqlConnection(constr);
      
            SqlCommand cmd2 = new SqlCommand("SELECT [CID],Max(CaseNo) as caseno FROM [Evaluation] where CID=@CID group by CID", scon);
           //SqlDataReader reader2 = cmd2.ExecuteReader();
           // scon.Open();
          //  cmd2.Parameters.AddWithValue("@CID", Label1.Text);
 //   cmd2.ExecuteNonQuery();
  //  scon.Close();
         //   GridView1.DataSource = reader2;
           // GridView1.DataBind();


            scon.Open();
            cmd2.Parameters.AddWithValue("@CID", Label1.Text);

            SqlDataReader reader2 = cmd2.ExecuteReader();



            if (reader2.Read())
            {
                //TextBox1.Text = reader2["FMstatust"].ToString();
                Label2.Text = reader2["caseno"].ToString();
                //     RadioButton1.Text = reader2["FMstatust"].ToString();
            }
            else
            {
                //MessageBox("ไม่พบเลขบัตรครับ");
            }
            scon.Close();
            reader2.Close();
           
        
        }

               protected void Button1_Click(object sender, EventArgs e)
               {

               }
    }
}